<template>
    <div class="login-wrapper">
      <h3>代理登录</h3>
      <ul>
        <li><el-input type="text" v-model="login.username"  placeholder="账号"></el-input></li>
        <li><el-input type="password" v-model="login.password"  placeholder="密码"></el-input></li>
        <li><el-button type="primary" style="width:100%;" @click.native.prevent="loginSubmit" :loading="logining">登录</el-button></li>
      </ul>
    </div>
</template>

<script>
    export default {
      data(){
        return{
          logining: false,
          login: {
            username: '',
            password: ''
          },
        }
      },
      created(){
        // let getToken = this.$route.query.token
        let getToken = this.GetQueryString("token")
        var domain = window.location.host;
        let token = 'Bearer ' + getToken
        // let token = 'Bearer eyJhbGciOiJIUzI1NiJ9.eyJpZCI6Nzc1LCJ1c2VybmFtZSI6IndodzY2NiIsInJlZ2lzdGVyX2F0IjoxNTQyMzMzMjI1ODY4LCJsYXN0X2xvZ2luX2F0IjoxNTQyMzczNzU2ODc4LCJlbmFibGVkIjoxfQ.lTbRVAspUg9Q5cD4DDJhEP2l1tGrVVkaG0GFmz0eTqY'
        if(getToken){
          sessionStorage.setItem('token',token)
          location.href ='http://'+ domain + '/#/index'
        }
      },
      methods:{
        loginSubmit(){
          if(this.login.username == ''){
            this.$message({message: '请输入账号', type: 'error',duration:1200});
          }else if(this.login.password == ''){
            this.$message({message: '请输入密码', type: 'error',duration:1200});
          }else{
            this.$message({message: '帐号或密码输入错误', type: 'error',duration:1200});
          }
        }
      }
    }
</script>

<style scoped lang="stylus">
  .login-wrapper
    width:2.5rem
    position fixed
    left:50%;
    top:40%;
    transform translate(-50%,-50%)
    &>h3
      font-size:.2rem
      color:#333
      text-align center
      margin-bottom .5rem
    &>ul>li
      margin-bottom .2rem
</style>
